<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="edu.upeu.lp1.common.Conexion" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form action="UserSave.jsp">
            <br> <input type="hidden" name="go" value="Create">
            <br>UserId: <input type="text" name="UserId">
            <br>Name: <input type="text" name="Name">
            <br>Login: <input type="text" name="Login">
            <br>password: <input type="text" name="Password">
            <br>forcepasswordChange: <input type="text" name="ForcePasswordChange">
            <br>Email: <input type="text" name="Email">
            <br>privilege: <input type="text" name="privilege">
            <br>ActiveAccount: <input type="text" name="ActiveAccount">
            <br>DateCreate: <input type="text" name="DateCreate">
            <br><input type="submit">
        </form>
<%
        Conexion conn = new Conexion();
        try {           
            String qry="select * from User";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ResultSet rs= ps.executeQuery();
            while(rs.next())
                out.println(
                        "<a href='UserForm.jsp?UserId="+rs.getString("UserId")+"'>Edit</a> "+
                        rs.getString("UserId")+ " "+
                        rs.getString("Name")+ " "+
                        rs.getString("Login")+ " "+
                        rs.getString("Password")+ " "+
                        rs.getString("ForcePasswordChange")+ " "+
                        rs.getString("Email")+ " "+
                        rs.getString("privilege")+ " "+
                        rs.getString("ActiveAccount")+ " "+
                        rs.getString("DateCreate")+ "<br>");
            conn.close();
        } catch (Exception e) {
            out.print("error " +e.getMessage());
        }       
%>              
    </body>
</html>